package jtk.project4.fleet.ibatis.dao;

import java.sql.SQLException;
import java.util.List;

import jtk.project4.fleet.domain.Parts;
import jtk.project4.fleet.domain.Vendor;

public class PartsDao extends IbatisDao{
	
	public List selectParts() throws SQLException {
		List selectParts = null;
			selectParts =getSqlMap().queryForList("SELECT_ALL_PARTS", null);
		return selectParts;
	}

	public int deleteParts(Parts parts) throws SQLException{
		return (int) getSqlMap().delete("DELETE_PARTS", parts);
	}
	
	public int updateParts(Parts parts) throws SQLException{
		return (int) getSqlMap().update("UPDATE_PARTS", parts);
	}
	
	public Parts insertParts(Parts parts) throws SQLException{
		return (Parts) getSqlMap().insert("INSERT_PARTS", parts);
	}

	
		
	public static void main (String args[]) throws SQLException{
		Parts parts;
		List <Parts> Lparts;
		parts = new Parts();
		
//		parts.setCatId(13);
//		new PartsDao().insertParts(parts);
		//select
//		Lparts = new PartsDao().selectParts();
//		System.out.println(Lparts.size());
//		
		//insert
		//parts.setPartId(62);
		//parts.setName("Rio Dermawan");
		//new PartsDao().insertParts(parts);
		
		//delete
		//parts.setPartId(40);
		//new PartsDao().deleteParts(parts);
		
		//update
		//parts.setPartId(41);
		//parts.setName("Dina Rahmadhani");
		//new PartsDao().updateParts(parts);
		}
	
}